#!/bin/bash
# 清除旧环境
rm -rf ~/JDK21
sed -i '/JAVA_HOME/d' ~/.bash_profile

# 下载JDK21
# wget -P ~/Test1/ https://download.oracle.com/java/21/archive/jdk-21.0.6_linux-x64_bin.tar.gz

# 解压安装包
tar -xzf ~/Test1/jdk-21.0.6_linux-x64_bin.tar.gz -C ~/
mv ~/jdk-21.0.6 ~/JDK21

# 配置环境变量
echo "JAVA_HOME=~/JDK21" >> ~/.bash_profile
echo 'PATH=$PATH:$JAVA_HOME/bin' >> ~/.bash_profile
echo 'PATH=$PATH:$JAVA_HOME/jre/bin' >> ~/.bash_profile

# 刷新环境变量
source ~/.bash_profile
echo "JDK21安装完成！"
